# import socket
#
# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# s.connect(("127.0.0.1", 8001))
# str1 = input("请输入信息")
# s.sendall(str1.encode())
# data = s.recv(1024)
# print(data.decode())
# s.close()


import socket
import os

s = socket.socket()

s.connect(("127.0.0.1", 8080))

a = s.recv(1024)
str1 = str(a, encoding="utf-8")
print(str1)

size = os.stat("20201310.txt").st_size
s.sendall(bytes(str(size), encoding="utf-8"))
respon = s.recv(1024)
print(respon.decode())
with open("20201310.txt", "rb") as f:
    for line in f:
        s.sendall(line)
b = s.recv(1024)
str2 = str(b, encoding="utf-8")
print(str2)


# import socket
# import os
#
# obj = socket.socket()
#
# obj.connect(("127.0.0.1",8080))
#
# ret_bytes = obj.recv(1024)
# ret_str = str(ret_bytes,encoding="utf-8")
# print(ret_str)
#
# size = os.stat("20201316.txt").st_size
# obj.sendall(bytes(str(size),encoding="utf-8"))
#
# obj.recv(1024)
#
# with open("20201316.txt","rb") as f:
#     for line in f:
#         obj.sendall(line)